package main.newViz;

import framework.Game;
import framework.GameRenderer;

import java.util.HashSet;
import java.util.Set;

/**
 * Date: 19.05.2008
 * Time: 20:25:29
 *
 * @author Denis DIR Rozhnev
 */
class Config {
    private Set<Observer> observers;

    private Game game;
    private GameRenderer renderer;

    public Config() {
    }

    public Config(Game game, GameRenderer renderer) {
        this.game = game;
        this.renderer = renderer;
    }

    public Game getGame() {
        return game;
    }

    public GameRenderer getRenderer() {
        return renderer;
    }

    void registerObserver(Observer observer) {
        getObservers().add(observer);
    }

    private Set<Observer> getObservers() {
        if (observers == null)
            observers = new HashSet<Observer>();
        return observers;
    }

    void setup(Config config) {
        for (Observer observer : getObservers()) {
            observer.configUpdate(config);
        }
    }

    void setup(Game game, GameRenderer renderer) {
        this.game = game;
        this.renderer = renderer;
        setup(this);
    }

    interface Observer {
        public void configUpdate(Config config);
    }
}
